<template>
	<div>
		<div>
			<el-form ref="declareForm" :model="declareInfo" :rules="rules" label-position="left" label-width="95px">
				<el-form-item label="公司名" prop="baseName">
					<el-input size="small" v-model="declareInfo.baseName" placeholder="请输入公司名" style="width: 280px;"></el-input>
				</el-form-item>
				<el-form-item label="所在城市" prop="city">
					<el-input size="small" v-model="declareInfo.city" placeholder="请输入公司所在城市" style="width: 180px;"></el-input>
				</el-form-item>
				<el-form-item label="详细地址" prop="address">
					<el-input v-model="declareInfo.address" type="textarea" style="width: 350px;" 
					placeholder="请输入公司详细地址" :autosize="{ minRows: 2, maxRows: 4}"></el-input>
				</el-form-item>
				<el-form-item label="可实习岗位" prop="position">
					<el-input v-model="declareInfo.position" type="textarea" autosize placeholder="请输入可提供的实习岗位(中间用;隔开)" style="width: 350px;"></el-input>
				</el-form-item>
				<el-form-item label="公司简介" prop="introduction">
					<el-input v-model="declareInfo.introduction" type="textarea" style="width: 350px;" placeholder="请输入该公司的简介"
					:autosize="{ minRows: 6, maxRows: 10}" maxlength="100" show-word-limit></el-input>
				</el-form-item>
			</el-form>
		</div>
		<div class="formBtn">
			<el-button type="primary" @click="clearAll" style="margin-right: 20px;">重置</el-button>
			<el-button type="primary" @click="submit">提交</el-button>
		</div>
	</div>
</template>

<script>
	export default {
		data() {
			return {
				declareInfo: {},
				rules:{
				    baseName: [{required: true, message: '请输入公司名',trigger: 'blur'}],
				    city: [{required: true, message: '请输入公司所在城市', trigger: 'blur'}],
				    address: [{required: true, message: '请输入公司详细地址', trigger: 'blur'}],
				    position: [{required: true, message: '请输入可实习岗位', trigger: 'blur'}],
					introduction: [{required: true, message: '请输入公司简介', trigger: 'blur'}],
				},
			}
		},
		methods:{
			clearAll(){
				this.declareInfo = {};
			},
			submit() {
				this.$refs['declareForm'].validate(valid => {
					if (valid) {
						this.$confirm('此操作将提交申报内容,且一经提交无法修改, 是否继续?', '提示', {
							confirmButtonText: '确定',
							cancelButtonText: '取消',
							type: 'warning'
						}).then(() => {
							this.postRequest("/base/declare/", this.declareInfo).then(resp => {
								if (resp) {
									this.clearAll();
								}
							})
						}).catch(() => {
							this.$message({
								type: 'info',
								message: '已取消提交'
							});
						});
					}
				})
			},
		}
	}
</script>

<style scoped>
	.formBtn{
		margin-top: 50px;
		margin-left: 100px;
	}
</style>
